# -*- coding: utf-8 -*- 
# @Time : 2020/9/15 17:38 
# @Author : hogan

import requests
from lxml import etree
import pyperclip
import time

headrs = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'Content-Length': '15',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Cookie': 'UM_distinctid=173c6848ecab2c-0104430050ba1a-4353761-1fa400-173c6848ecbb2f; CNZZDATA1278106425=1799040588-1596760554-%7C1596843881',
    'Host': 'www.lookdiv.com',
    'Referer': 'http://www.lookdiv.com/',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
}

html = requests.post(url='http://www.lookdiv.com/index/index/indexcode.html', headers=headrs,
                     data={'key': 'lookdiv.com'}).content.decode()
# with open("eq.html", "w", encoding="utf-8") as  f:
#     f.write(eq)

xpath_data = etree.HTML(html)

print("正在获取。。。。。，此激活码会定期更新，支持所有版本，所有软件")
print("verion:1.1 ")
print("author：hogan")
print("mail:hoganmail@163.com")
try:
    code = xpath_data.xpath('//*[@id="subsModal"]/div/div/div/textarea/text()')[0].replace("\r\n", "")
except:
    try:
        code = xpath_data.xpath('//*[@id="subsModal"]/div/div/div/textarea/text()')[0].replace("\r\n", "")
    except:
        code = xpath_data.xpath('//*[@id="subsModal"]/div/div/div/textarea/text()')[0].replace("\r\n", "")
pyperclip.copy(code)
print(code)
print("已复制到剪切板。。")
with open("code.txt","w",encoding="utf-8") as f:
    f.write(code)
time.sleep(2)


